/*
 * @Author: DUST
 * @Date: 2023-05-26 15:23:27
 * @LastEditors: DUST
 * @LastEditTime: 2023-07-04 15:06:35
 * @FilePath: \koa-node-ts\app\db\index.ts
 * @Description:
 * undefined
 */
import sequelize from "./sequelize";
import path from "path";
const db = async () => {
  try {
    // 测试链接
    await sequelize.authenticate().then(() => {
      console.log("数据库连接成功！");
      // 同步所有模型
      sequelize.sync({ force: false, alter: true }).then((res) => {
        console.log("所有模型均已成功同步.");
      });
    });
    
  } catch (error) {
    console.error("数据库连接失败", error);
  }
};

export default db;
